home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
vb_clk2
/
frm_clk.frm
< prev
next >
Wrap
Text File
|
1995-09-06
|
7KB
|
227 lines
VERSION 2.00
Begin Form FRM_Clock
AutoRedraw = -1 'True
BorderStyle = 0 'None
ClientHeight = 240
ClientLeft = 7260
ClientTop = 5790
ClientWidth = 1560
ControlBox = 0 'False
Height = 645
Icon = FRM_CLK.FRX:0000
Left = 7200
LinkMode = 1 'Source
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 240
ScaleWidth = 1560
Top = 5445
Width = 1680
Begin Timer Timer1
Interval = 500
Left = 0
Top = 0
End
End
DefInt A-Z
Dim IniFile$
Dim MyRect As RECT
Dim AllowFormToMove
Dim MStartX
Dim MStartY
Dim ClassName As String * 15
Dim cn$
Dim Wnd As Integer
Sub DisplayInfo ()
If IsFloat Then
Wnd = WindowFromPoint(15, 15)
If (Wnd > 0) And (Wnd <> FRM_Clock.hWnd) Then
b% = GetClassName(Wnd, ClassName, 15)
cn$ = TrimZeroTerm(ClassName)
If cn$ <> "BlankerClass" Then GetWindowRect Wnd, MyRect
If (MyRect.Left = 0) And (MyRect.Top = 0) And (cn$ = "NFMWClass" Or cn$ = "#32769") Then
MyRect.Right = MyRect.Right + 4
MyRect.Top = -4
End If
FRM_Clock.Left = Pixels_To_Twips(MyRect.Right) - (FRM_Clock.Width + 700)
FRM_Clock.Top = Pixels_To_Twips(MyRect.Top) + 75
End If
End If
msg$ = ""
For X% = 1 To MaxItems
msg$ = msg$ + GetInfo(DispInfo(X%))
Next X%
msg$ = RTrim$(msg$)
FRM_Clock.Backcolor = bColour
FRM_Clock.ForeColor = fColour
FRM_Clock.CurrentX = ((FRM_Clock.Width - TextWidth(msg$)) / 2)
FRM_Clock.CurrentY = ((FRM_Clock.Height - TextHeight(msg$)) / 2)
FRM_Clock.Print msg$
End Sub
Sub Form_DblClick ()
ShowOptions
End Sub
Sub Form_Load ()
Const TempLen = 250
Dim TempStr As String * TempLen
On_top% = SetWindowPos(FRM_Clock.hWnd, -1, 0, 0, 0, 0, &H2 Or &H1 Or &H40 Or &H10)
sm% = FRM_Clock.scalemode
FRM_Clock.scalemode = 1
Scale_Twip = FRM_Clock.ScaleWidth
FRM_Clock.scalemode = 3
Scale_Pixel = FRM_Clock.ScaleWidth
FRM_Clock.scalemode = sm%
' get windows directory for INI file
uh% = GetWindowsDirectory(TempStr, TempLen)
IniFile$ = TrimZeroTerm(TempStr)
If Right$(IniFile$, 1) <> "\" Then IniFile$ = IniFile$ + "\"
IniFile$ = IniFile$ + "VBCLOCK.INI"
' get & set position from INI file
FRM_Clock.Top = GetPrivateProfileInt("Position", "Top", Int(Screen.Height * .003), IniFile$)
FRM_Clock.Left = GetPrivateProfileInt("Position", "Left", Int(Screen.Width * .71), IniFile$)
IsFloat = GetPrivateProfileInt("Position", "Floating", True, IniFile$)
If IsFloat And (FRM_Clock.Left <= Pixels_To_Twips(15)) And (FRM_Clock.Top <= Pixels_To_Twips(15)) Then FRM_Clock.Left = Pixels_To_Twips(20)
' get & set colours from INI file
uh% = GetPrivateProfileString("Colour", "Background", Format$(ACTIVE_TITLE_BAR), TempStr, TempLen, IniFile$)
bColour = Val(TempStr)
uh% = GetPrivateProfileString("Colour", "Foreground", Format$(INACTIVE_TITLE_BAR), TempStr, TempLen, IniFile$)
fColour = Val(TempStr)
' get & set typeface
uh% = GetPrivateProfileString("Typeface", "Font", "MS Sans Serif", TempStr, TempLen, IniFile$)
DispFont = TrimZeroTerm(TempStr)
uh% = GetPrivateProfileString("Typeface", "Fontsize", "8.25", TempStr, TempLen, IniFile$)
DispFontSize = Val(TempStr)
' get & set display
DispInfo(1) = GetPrivateProfileInt("Display", "Info1", 1, IniFile$)
DispInfo(2) = GetPrivateProfileInt("Display", "Info2", 2, IniFile$)
DispInfo(3) = GetPrivateProfileInt("Display", "Info3", 5, IniFile$)
DispInfo(4) = GetPrivateProfileInt("Display", "Info4", 7, IniFile$)
For X% = 5 To MaxItems
nm$ = "Info" + Format$(X%)
DispInfo(X%) = GetPrivateProfileInt("Display", nm$, 6, IniFile$)
Next X%
' get & set alarm
IsAlarm = False
uh% = GetPrivateProfileString("Alarm", "Time", "0", TempStr, TempLen, IniFile$)
AlarmTime = Val(TempStr)
If AlarmTime > Now Then
IsAlarm = True
uh% = GetPrivateProfileString("Alarm", "Message", "", TempStr, TempLen, IniFile$)
AlarmMessage = TrimZeroTerm(TempStr)
End If
SetForm
DisplayInfo
End Sub
Sub Form_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
If (Button And LEFT_BUTTON) > 0 Then
AllowFormToMove = True
MStartX = X
MStartY = Y
MousePointer = SIZE_POINTER
End If
End Sub
Sub Form_MouseMove (Button As Integer, Shift As Integer, X As Single, Y As Single)
If AllowFormToMove Then Move FRM_Clock.Left + (X - MStartX), FRM_Clock.Top + (Y - MStartY)
End Sub
Sub Form_MouseUp (Button As Integer, Shift As Integer, X As Single, Y As Single)
RButt = (Button And RIGHT_BUTTON) > 0
LButt = (Button And LEFT_BUTTON) > 0
Ctrl = (Shift And CTRL_MASK) > 0
If LButt Then
AllowFormToMove = False
MousePointer = DEFAULT
ElseIf RButt Then
Select Case Ctrl
Case False
ShowOptions
Case True
End
End Select
End If
End Sub
Sub Form_Unload (Cancel As Integer)
WriteProfile
End Sub
Sub SetForm ()
FRM_Clock.FontName = DispFont
FRM_Clock.FontSize = DispFontSize
FRM_Clock.FontBold = True
msg$ = ""
For X% = 1 To MaxItems
msg$ = msg$ + GetInfo(DispInfo(X%))
Next X%
msg$ = RTrim$(msg$)
FRM_Clock.Width = TextWidth(msg$) * 1.05
FRM_Clock.Height = TextHeight(msg$) * 1.15
End Sub
Sub ShowOptions ()
Timer1.Enabled = False
FRM_Opts.Show 1
Timer1.Enabled = True
SetForm
WriteProfile
DisplayInfo
End Sub
Sub Timer1_Timer ()
DisplayInfo
If IsAlarm Then
If AlarmTime <= Now Then
MessageBeep (48)
If AlarmMessage = "" Then AlarmMessage = "It's that time!"
MsgBox AlarmMessage, 48, "Alarm"
IsAlarm = False
FRM_Opts.CHK_Alarm.Value = 0
End If
End If
End Sub
Sub WriteProfile ()
uh = WritePrivateProfileString("Colour", "Background", Format$(bColour), IniFile$)
uh = WritePrivateProfileString("Colour", "Foreground", Format$(fColour), IniFile$)
uh = WritePrivateProfileString("Typeface", "Font", DispFont, IniFile$)
uh = WritePrivateProfileString("Typeface", "Fontsize", Format$(DispFontSize), IniFile$)
uh = WritePrivateProfileString("Position", "Floating", Format$(IsFloat), IniFile$)
If Not IsFloat Then
uh = WritePrivateProfileString("Position", "Top", Format$(FRM_Clock.Top), IniFile$)
uh = WritePrivateProfileString("Position", "Left", Format$(FRM_Clock.Left), IniFile$)
End If
If IsAlarm Then
uh = WritePrivateProfileString("Alarm", "Time", Format$(AlarmTime), IniFile$)
uh = WritePrivateProfileString("Alarm", "Message", AlarmMessage, IniFile$)
End If
For X% = 1 To MaxItems
nm$ = "Info" + Format$(X%)
uh = WritePrivateProfileString("Display", nm$, Format$(DispInfo(X%)), IniFile$)
Next X%
End Sub